<?php
use yii\helpers\Html;
use yii\helpers\Url;
?>
<link href="/static/css/public-same.css" rel="stylesheet">
<link href="/static/css/question.css" rel="stylesheet">
<div class="main-area QA-area" style="min-height: 100%; background: #f5f5f5;">
<div class="container">
<div class="column-layout">
<!-- main-area-left start  -->
<div class="column-col main-area-left">
<div class="main-area-leftin" style="min-width: 100%;">
<h3>搜索"<?= Html::encode($search_content);?>"相关内容有<?= Html::encode($count);?>的结果</h3>
    <style>
        .zhi_font{
            width: 130px;
            overflow: hidden;
        }
    </style>
<div class="ibox">
    <div class="ibox-in">

        <!--直播课程-->
	    <?php if(!empty($search['direct'])){?>
        <div class="zy_index_box">
            <p class="zy_index_box_tit color99 font14">
                <a href="http://www.bwphp.com/index.php/course/index?2[type]=11" class="font22 s1 color33" target="_blank">直播课程</a>
                <span class="s2">成为一名PHP优秀工程师，从零开始</span>
	            <?php if($all_count['direct'][0]['count'] <= 8){ ?>
                <a href="javascript:void(0)" class="zy_amore2">搜索<b><?= Html::encode($all_count['direct'][0]['count'])?></b>条相关结果</a>
	            <?php }elseif($all_count['direct'][0]['count'] > 8){ ?>
                <a href="http://www.bwphp.com/index.php/course/index" class="zy_amore2">查看更多直播课程 &gt;</a>
	            <?php }else{ ?>
		            <a href="javascript:void(0)" class="zy_amore2">无数据</a>
	            <?php } ?>
                <a class="zy_amore" href="http://www.bwphp.com/course/">更多 &gt;</a>
            </p>
            <ul class="zy_slClass">

		            <?php foreach($search['direct'] as $k=>$v){?>
	                <li>
	                    <div class="zhi_img"><img style="display: inline;" alt="<?= Html::encode($v['course_name'])?>" class="lazy" src="http://files.bwphp.com/file/image/show/?path=<?= Html::encode($v['course_thumb'])?>" data-original="http://files.bwphp.com/file/image/show/?path=<?= Html::encode($v['course_thumb'])?>" height="100px" width="80px"></div>
	                    <div class="zhi_font color66">
	                        <p class="color00 font16 p1">
		                        <?php if(strlen($v['course_name']) > 8){?>
			                        <?= Html::encode(substr($v['course_name'],0,21))?>...
			                        <?php } else {?>
		                        <?= Html::encode($v['course_name'])?>
		                        <?php } ?>
	                        </p>
	                        <p>开始：<?= date("m-d H:i:s",$v['start_time'])?><br>结束：<?= date("m-d H:i:s",$v['end_time'])?></p>
	                        <p>介绍：<?= Html::encode(substr($v['describe'],0,30))?>...</p>
	                        <p class="color99"><?= Html::encode($v['apply_num'])?>人正在学习</p>
	                    </div>
	                    <a title="<?= Html::encode($v['course_name'])?>" href="http://www.bwphp.com/index.php/course/course-detail?course_id=<?= Html::encode($v['course_id'])?>"></a>
	                </li>
				<?php } ?>
            </ul>
        </div>
		<?php } ?>
        
        <!--视频课程-->
	    <?php if(!empty($search['video'])){?>
        <div class="zy_index_box">
            <p class="zy_index_box_tit color99 font14"><a href="http://www.bwphp.com/index.php/course/index?2[type]=2" class="font22 s1 color33" target="_blank">视频课程</a><span class="s2">权威培训，专业老师，一流的学习平台</span>
	            <?php if($all_count['video'][0]['count'] <= 8){ ?>
		            <a href="javascript:void(0)" class="zy_amore2">搜索<b><?= Html::encode($all_count['video'][0]['count'])?></b>条相关结果</a>
	            <?php }elseif($all_count['video'][0]['count'] > 8){ ?>
	            <a href="http://www.bwphp.com/index.php/course/index?2%5Btype%5D=2" class="zy_amore2" target="_blank">查看更多视频课程 &gt;</a>
	            <a class="zy_amore" href="http://www.bwphp.com/course/list/" target="_blank">更多 &gt;</a>
            </p>
            <ul class="zy_course_list">

	                <?php foreach($search['video'] as $k=>$v){?>
                        <li><a title="<?= Html::encode($v['course_name'])?>" href="http://www.bwphp.com/index.php/course/course-detail?course_id=<?= Html::encode($v['course_id'])?>" target="_blank">
                        <p><img alt="<?= Html::encode($v['course_name'])?>" src="http://files.bwphp.com/file/image/show/?path=<?= Html::encode($v['course_thumb'])?>" data-original="http://files.bwphp.com/file/image/show/?path=<?= Html::encode($v['course_thumb'])?>" class="lazy" style="display: inline;"></p>
                        <div class="">
                            <p class="font14"><?= Html::encode($v['course_name'])?></p>
                            <p class="color99"><?= Html::encode($v['apply_num'])?>人正在学习</p>
                        </div>
                    </a></li>
	            <?php } ?>
            </ul>
        </div>
		<?php }} ?>

	    <!--下载-->
	    <?php if(!empty($search['soft'])){?>
		    <div class="zy_index_box">
		    <p class="zy_index_box_tit color99 font14"><a href="http://www.bwphp.com/index.php/download/index" class="font22 s1 color33" target="_blank">下载</a><span class="s2">在线互动式软件下载平台</span>
		    <?php if($all_count['soft'] <= 8){ ?>
			    <a href="javascript:void(0)" class="zy_amore2">搜索<b><?= Html::encode($all_count['soft'])?></b>条相关结果</a>
		    <?php }elseif($all_count['soft'] > 8){ ?>
			    <a href="http://www.bwphp.com/index.php/download/index" class="zy_amore2" target="_blank">查看更多软件 &gt;</a>
			<?php } else {?>
			    <a class="zy_amore" href="http://www.bwphp.com/index.php/download/index" target="_blank">更多 &gt;</a>
			<?php } ?>
			    </p>
			    <ul class="zy_course_list">
				    <?php foreach($search['soft'] as $k=>$val){?>
					    <li class='tuwen'   style="position:relative; border-radius:15px;" data-id='<?=$val['soft_id']?>'>

						    <p><img alt="<?=$val['soft_name']?>" style='padding:5px; text-align:center; border-radius:15px; border:1px #dcdbd1 solid' src="<?= 'http://files.bwphp.com/file/image/show/275/175?path='.$val['soft_thumb']?>"></p>

						    <div style='margin-left:10px;'>
							    <p>软件名称：<span class="font14"><?=Html::encode($val['soft_name'])?></span></p>
							    <p>类别：<span class="color99"><?=Html::encode($val['softcate_name'])?></span></p>
							    <p>软件大小：<span class="color99"><?=Html::encode($val['soft_size'])?>/M</span></p>
							    <p>所需积分：<span class="color99"><?=Html::encode($val['soft_points'])?></span></p>
							    <p>下载次数：<span class="color99"><?=Html::encode($val['soft_down_count'])?></span></p>
						    </div>
						    <div id='down<?=$val['soft_id']?>' style='border-radius:15px; position: absolute;  width:100%; height:100%;top:0px;display: none;z-index:49; padding:0;'>
							    <div  style="background:black; z-index:50; border-radius:15px; position: absolute;  width:100%; height:100%;  opacity:0.6;  ">
								    <div style='height:200px;'>
									    <h4>相关课程：</h4> <br/>
									    <ul id='now<?=$val['soft_id']?>' ></ul>
								    </div>
							    </div>
							    <div style="height:90px; position: absolute; top:220; left:10px; z-index:51">
								    <a class='downloadclass' style='background:#0997F7;border-radius:20px; color:white; width:160px; text-align:center; margin-left:29px; font-size:20;' href='javascript:void(0)' data-id='<?=$val['soft_id']?>' >点击下载</a>
							    </div>
						    </div>
					    </li>
				    <?php } ?>
			    </ul>
			    </div>
		    <?php } ?>


	    <!--有问必答-->
	    <?php if(!empty($search['question'])){?>
		    <div class="zy_index_box">
		    <p class="zy_index_box_tit color99 font14"><a href="http://www.bwphp.com/index.php/questions/index" class="font22 s1 color33" target="_blank">有问必答</a><span class="s2">权威培训，专业老师，一流的学习平台</span>
		    <?php if($all_count['question'] <= 8){ ?>
			    <a href="javascript:void(0)" class="zy_amore2">搜索<b><?= Html::encode($all_count['question'])?></b>条相关结果</a>
		    <?php }elseif($all_count['question'] > 8){ ?>
			    <a href="http://www.bwphp.com/index.php/questions/index" class="zy_amore2" target="_blank">查看更多视频课程 &gt;</a>
			<?php } else { ?>
			    <a class="zy_amore" href="http://www.bwphp.com/index.php/questions/index" target="_blank">更多 &gt;</a>
			<?php } ?>
			    </p>
			    <div class="QA-list">

				    <?php foreach($search['question'] as $k=>$val){?>
					    <div class="item">
						    <div class="col-left">
							    <div class="col-in">
								    <div class="u-photo-box">
									    <a href="javascript:void(0);" target="_blank" id="40843" class="u-photo u-photo-btn">
										    <img src="http://files.bwphp.com/file/image/show/50/50?path=<?= Html::encode($val['user_thumb'])?>" alt="" height="50" width="50">
									    </a>

									    <i class="ico ico-umark-2"></i>

								    </div>
								    <span class="u-name"><?= Html::encode($val['user_name']);?></span>

							    </div>
						    </div>
						    <div class="col-right">
							    <div class="col-in item-r-main">
								    <h3>
									    <a href="<?= Url::to(['questions/details'])?>?ques_id=<?php echo $val['ques_id']?>" class="count" name="<?= Html::encode($val['ques_id']) ?>" target="_blank">

										    <?= Html::encode($val['ques_name'])?>
									    </a>
								    </h3>
								    <div class="item-r-A">

									    <span class="tips">[最新回答]</span>
									    <a href="<?= Url::to(['questions/details'])?>?ques_id=<?php echo $val['ques_id']?>">
										    <?php


										    echo $val['answers']['answer_content'];

										    ?>
									    </a>

								    </div>
								    <div class="hot-tag-group">

									    <a href="javascript:void(0);" class="hot-tag"><?= Html::encode($val['queslabel_name'])?></a>
								    </div>
								    <div class="item-r-foot ask-item-r-foot">
									    <div class="col-left" style="width: 26% !important;">

							<span class="datetime">
								<?php
								$dur = time()-$val['ques_addtime'];
								/*暂时没想到怎么做、先做成这样的*/
								if($dur<60){
									echo $dur."秒前";
								}else{
									if($dur<3600){
										echo floor($dur/60)."分钟前";
									}else{
										if($dur<86400){
											echo floor($dur/3600)."小时前";
										}else{
											if($dur<604800){
												echo floor($dur/86400)."天前";
											}else{
												if($dur<2592000){
													echo floor($dur/604800)."周前";
												}else{
													if($dur<31104000){
														echo floor($dur/2592000)."月前";
													}else{
														if($dur>31104000){
															echo floor($dur/31104000)."年前";
														}
													}
												}
											}
										}
									}
								}
								echo $year;
								?>
							</span>

									    </div>

									    <?php if(!empty($val['course_name'])){?>
										    <a href=''>来源:<?= Html::encode($val['course_name'])?></a>
									    <?php }?>
									    <div class="col-right">
							<span class="i-item">
								<a href="javascript:void(0);" target="_blank">回答(<?= Html::encode($val['ques_answersum'])?>)</a>
							</span>
							<span class="i-item">
								<a href="javascript:void(0);" target="_blank">浏览(<?= Html::encode($val['ques_viewsum'])?>)</a>
							</span>
									    </div>
								    </div>
							    </div>
						    </div>
					    </div>
				    <?php } ?>
			    </div>
			    </div>
		    <?php } ?>





        <!--资讯头部-->
	    <?php if(!empty($search['article'])){?>
        <div class="zy_index_box" style="padding-top: 10px;">
            <p class="zy_index_box_tit color99 font14">
                <a href="http://www.bwphp.com/index.php/operate/index" class="font22 s1 color33" target="_blank">行业资讯</a>
                <span class="s2">第一时间了解行业新闻，第一时间分享行业资源</span>
	            <?php if($all_count['article'] <= 8){ ?>
		            <a href="javascript:void(0)" class="zy_amore2">搜索<b><?= Html::encode($all_count['article'])?></b>条相关结果</a>
	            <?php }elseif($all_count['article'] > 8){ ?>
                    <a href="http://www.bwphp.com/index.php/operate/index" class="zy_amore2" target="_blank">查看更多资讯 &gt;</a>
	            <?php }else{ ?>
		            无数据
	            <?php } ?>
                <a class="zy_amore" href="#" target="_blank">更多 &gt;</a></p>
        </div>
        
        <!-- 资讯列表  -->
        <div class="ibox-body">
            <div class="article-list">

                    <?php foreach($search['article'] as $k=>$v){?>
			            <!-- item -->
			            <div class="item">
			                <div class="col-left">
			                    <a target="_blank" href="http://www.bwphp.com/index.php/operate/detail?article_id=<?= Html::encode($v['article_id'])?>" class="col-in count">
			                        <img alt="" src="http://admin.bwphp.com/<?= Html::encode($v['article_thumb'])?>">
			                    </a>
			                </div>
			                <div class="col-right">
			                    <div class="col-in">
			                        <h3><a target="_blank" href="http://www.bwphp.com/index.php/operate/detail?article_id=<?= Html::encode($v['article_id'])?>" class="count">
			                        <?= Html::encode(substr($v['article_title'],0,90))?>...</a></h3>
			                        <p style="word-break:break-all" class="article-abstract"><?= Html::encode(substr($v['article_descripte'],0,300))?>...<a target="_blank" name="4" href="http://www.bwphp.com/index.php/operate/detail?article_id=<?= Html::encode($v['article_id'])?>" class="count">查看全文</a></p>

			                            <div class="article-about">
			                                <span class="hot-tag-group"><a href="#" class="hot-tag"><?= Html::encode($v['artlable_name'])?></a></span>
			                            </div>

			                        <div class="article-about">
			                            <div style="" class="article-about-user">

			                                <div>作者:<span class="u-name"><?= Html::encode($v['article_author'])?></span>
			                                </div>
			                                <span class="u-datetime">
							                    <?php
								                    $dur = time()-$v['article_addtime'];
								                    /*暂时没想到怎么做、先做成这样的*/
								                    if($dur<60){
									                    echo $dur."秒前";
								                    }else{
									                    if($dur<3600){
										                    echo floor($dur/60)."分钟前";
									                    }else{
										                    if($dur<86400){
											                    echo floor($dur/3600)."小时前";
										                    }else{
											                    if($dur<604800){
												                    echo floor($dur/86400)."天前";
											                    }else{
												                    if($dur<2592000){
													                    echo floor($dur/604800)."周前";
												                    }else{
													                    if($dur<31104000){
														                    echo floor($dur/2592000)."月前";
													                    }else{
														                    if($dur>31104000){
															                    echo floor($dur/31104000)."年前";
														                    }
													                    }
												                    }
											                    }
										                    }
									                    }
								                    }
								                    echo $year;
							                    ?>
			                                </span>

			                            </div>
			                            <div class="col-right">
			                                <span class="u-view">浏览(<?= Html::encode($v['article_count'])?>)</span>
			                            </div>
			                        </div>
			                    </div>
			                </div>
			            </div>
				<?php } ?>
            </div>

        </div>
	    <?php } ?>

	    <!--师资力量-->
	    <?php if(!empty($search['teacher'])){?>
		    <div class="zy_index_box">
		    <p class="zy_index_box_tit color99 font14"><a href="http://www.bwphp.com/index.php/course/index?2[type]=2" class="font22 s1 color33" target="_blank">师资力量</a><span class="s2">权威培训，专业老师，一流的学习平台</span>
		    <?php if($all_count['teacher'] <= 8){ ?>
			    <a href="javascript:void(0)" class="zy_amore2">搜索<b><?= Html::encode($all_count['teacher'])?></b>条相关结果</a>
		    <?php }elseif($all_count['teacher'] > 8){ ?>
			    <a href="http://www.bwphp.com/index.php/course/index?2%5Btype%5D=2" class="zy_amore2" target="_blank">查看更多视频课程 &gt;</a>
			<?php } else { ?>
			    <a class="zy_amore" href="http://www.bwphp.com/course/list/" target="_blank">更多 &gt;</a>
			<?php } ?>
			    </p>
			    <ul class="zy_ming_div">
				    <?php foreach($search['teacher'] as $k=>$v){ ?>
					    <li><a title="Sundy" href="http://www.bwphp.com/index.php/teacher/teacherinfo?teacher_id=<?= Html::encode($v['teacher_id'])?>" target="_blank">
							    <div class="marginB10 t3out"><img style="display: inline;" alt="<?= Html::encode($v['position_name'])?>" height="200px" width="250px" class="lazy" src="http://files.bwphp.com/file/image/show/200/200?path=<?= Html::encode($v['teacher_thumb'])?>" data-original="http://files.bwphp.com/<?= Html::encode($v['teacher_thumb'])?>"></div>
							    <p class="color33 font18 textC marginB10"><?= Html::encode($v['teacher_name'])?></p>
							    <p class="color99 pb"><?= Html::encode($v['teacher_desc'])?></p>
						    </a>
					    </li>
				    <?php } ?>
			    </ul>
			    </div>
		    <?php } ?>
    </div>
</div>
</div>
</div>
<!-- main-area-left end  -->

</div>
</div>
</div>
<script type="text/javascript">
	$(function(){
		var noid = 0;
		$('.tuwen').hover(function(){
			var id = $(this).attr('data-id');
			timer = setTimeout(function(){
				$('#down'+id).slideDown(100);
				if($('#now'+id).html()==''){
					if(noid==0){
						noid = noid+1;
						$.ajax({
							url:'http://www.bwphp.com/index.php/download/course',
							type: 'post',
							data:'soft_id='+id,
							dataType:'json',
							success:function(msg){
								str = '';
								for(var i=0;i<msg.length;i++){
									str+='<li style="background:black; text-align:center; color:white; overflow: hidden; height: 25px; " title='+msg[i]['course_name']+'>'+msg[i]['course_name']+'</li>';
								}
								$('#now'+id).append(str);

							},
							complete:function(){
								noid = 0;
							}
						});
					}
				}
			},500);
		},function(){
			var id = $(this).attr('data-id');
			//$('#now'+id).empty();
			clearTimeout(timer);
			$('#down'+id).slideUp(200);
		});

		$('.downloadclass').on('click',function(){
			var id = $(this).attr('data-id');
			$.ajax({
				url:'/index.php/download/downloadsoft',
				type: 'post',
				data:'soft_id='+id,
				dataType:'json',
				success:function(msg){
					if(msg.data==0) {
						jq('#loginModal').modal('show');
					}else if(msg.data==1){
						jq('#downloaderror').modal('show');
					}
				}
			});
		});
	});
</script>